home *** CD-ROM | disk | FTP | other *** search
/ El Mac 9 / El Mac 9.iso / Shareware / Applications / Charting Coach v1.5 / Charting Coach v1.dxr / 00513.ls < prev    next >
Encoding:
Text File  |  1996-04-08  |  11.9 KB  |  437 lines

  1. on startMovie
  2.   global askedToKeepChartin, usrName, pswd, oldDepth, forewarned, registered
  3.   cursor(4)
  4.   if ((the stageBottom - the stageTop) < 476) or ((the stageRight - the stageLeft) < 630) then
  5.     alert("The display must be set to 640 X 480 resolution or greater.")
  6.     quit()
  7.   end if
  8.   if the colorDepth < 8 then
  9.     set the colorDepth to 8
  10.   end if
  11.   if the colorDepth < 8 then
  12.     alert("The display is not set to use 8 bit (256) color or greater.  Charting Coach graphics will be distorted.  Please readjust the computer display bit depth.")
  13.   end if
  14.   puppetVisible(1, 48, 1)
  15.   puppetStatus(1, 48, 0)
  16.   initVars()
  17.   cursor(4)
  18.   set the keyDownScript to "if the key = return then dontPassEvent"
  19.   getTheDate()
  20.   setupPrint()
  21.   if the machineType = 256 then
  22.     openXLib(the pathName & "MovUtils.DLL")
  23.     openXLib(the pathName & "fileIO.DLL")
  24.   end if
  25.   put " " into field "userName"
  26.   put " " into field "passWord"
  27.   put EMPTY into field "comments"
  28.   put EMPTY into field "advice"
  29.   put EMPTY into field "basis"
  30.   put " " into field "problem"
  31.   readUserNames()
  32.   if (registered = "BVM") or (the frame = label("frontPage")) then
  33.     go("login")
  34.   else
  35.     go("register")
  36.   end if
  37.   cursor(0)
  38. end
  39.  
  40. on getTheDate
  41.   global theDate
  42.   if the machineType = 256 then
  43.     openXLib("getdate.dll")
  44.     set getDateXObj to getDate(mnew)
  45.     set theDate to getDateXObj(mGetDate)
  46.     getDateXObj(mdispose)
  47.     closeXLib("getdate.dll")
  48.   else
  49.     set theDate to datePack("getMachineDate")
  50.   end if
  51.   set theDate to string(theDate)
  52.   set theDate to string(chars(theDate, 5, 6) & "/" & chars(theDate, 7, 8) & "/" & chars(theDate, 3, 4))
  53. end
  54.  
  55. on register
  56.   global registered
  57.   set x to the text of field "register"
  58.   put EMPTY into field "register"
  59.   if (the number of chars in x = 10) and (x contains "B") and (x contains "V") and (x contains "M") and (x contains "3") then
  60.     go("login")
  61.     cursor(0)
  62.     set registered to "BVM"
  63.     resetUserNames()
  64.   else
  65.     cursor(0)
  66.     alert("Improper registration number.")
  67.     put EMPTY into field "register"
  68.   end if
  69. end
  70.  
  71. on setupPrint
  72.   global printer, gPropFont, gMonoFont
  73.   if the machineType = 256 then
  74.     set gPropFont to "arial"
  75.     set gMonoFont to "courier new"
  76.   else
  77.     set gPropFont to "helvetica"
  78.     set gMonoFont to "courier"
  79.   end if
  80.   if not objectp(printer) then
  81.     if the machineType = 256 then
  82.       openXLib(the pathName & "pmatic.dll")
  83.     end if
  84.     set printer to PrintOMatic(mnew)
  85.     if objectp(printer) then
  86.       if the machineType = 256 then
  87.         printer(mRegister, "10090739-939")
  88.       else
  89.         printer(mRegister, "11091751-406")
  90.       end if
  91.     end if
  92.   end if
  93. end
  94.  
  95. on stopMovie
  96.   global printer, oldDepth
  97.   go("leaving")
  98.   set the colorDepth to oldDepth
  99.   if objectp(printer) then
  100.     printer(mdispose)
  101.   end if
  102.   if the machineType = 256 then
  103.     closeXLib(the pathName & "pmatic.dll")
  104.     closeXLib(the pathName & "MovUtils.DLL")
  105.     closeXLib(the pathName & "fileIO.DLL")
  106.   end if
  107. end
  108.  
  109. on login
  110.   global usrName, pswd, cycleNo, userNo, currentCycleNo
  111.   set checkuser to word 1 of the text of field "username"
  112.   set checkpass to word 1 of the text of field "password"
  113.   set usrOK to 0
  114.   set pssOK to 0
  115.   set loginok to 0
  116.   set x to count(usrName)
  117.   if x > 0 then
  118.     repeat with i = 1 to x
  119.       if checkuser = getAt(usrName, i) then
  120.         set usrOK to 1
  121.         if checkpass = getAt(pswd, i) then
  122.           set userNo to i
  123.           set currentCycleNo to getAt(cycleNo, userNo)
  124.           readCycleInfo()
  125.           prepfrontpage()
  126.           cursor(0)
  127.           exit
  128.           next repeat
  129.         end if
  130.         cursor(0)
  131.         alert("Login Failed.  Please enter a correct password.")
  132.         go("loginPswd")
  133.         exit
  134.       end if
  135.     end repeat
  136.   else
  137.     cursor(0)
  138.     alert("Login Failed.  If this is the first time you're using this program, press the New User button.")
  139.     set usrOK to 1
  140.   end if
  141.   cursor(0)
  142.   if usrOK = 0 then
  143.     alert("Login Failed.  Please enter a correct username.")
  144.   end if
  145.   go("login")
  146.   cursor(0)
  147. end
  148.  
  149. on checkPsWrd
  150.   global pswd, userNo
  151.   if word 1 of the text of field "Password" = getAt(pswd, userNo) then
  152.     go("ChngPswrd")
  153.     cursor(0)
  154.   else
  155.     cursor(0)
  156.     alert("Incorrect Password.  Please try again.")
  157.     put EMPTY into field "Password"
  158.   end if
  159. end
  160.  
  161. on newPswd
  162.   global candidatePswd
  163.   cursor(0)
  164.   set checkPswd to the text of field "password"
  165.   set the text of field "password" to EMPTY
  166.   if the number of words in checkPswd > 1 then
  167.     alert("Please use a one word password without spaces.")
  168.   else
  169.     if the number of words in checkPswd = 1 then
  170.       set candidatePswd to word 1 of checkPswd
  171.       go("ConfirmNewPswd")
  172.     else
  173.       if the number of words in checkPswd = 0 then
  174.         go("ConfirmNoPswd")
  175.       end if
  176.     end if
  177.   end if
  178. end
  179.  
  180. on confirmPswd
  181.   global pswd, usrName, candidateUserName, candidatePswd
  182.   set checkPswd to word 1 of the text of field "password"
  183.   if checkPswd = candidatePswd then
  184.     append(usrName, capitalizeIT(candidateUserName))
  185.     append(pswd, candidatePswd)
  186.     confirmOK()
  187.   else
  188.     cursor(0)
  189.     alert("Confirmation Failed.  Re-enter your password.")
  190.     go("psWrd")
  191.   end if
  192. end
  193.  
  194. on changePswd
  195.   global pswd, checkPswd
  196.   set checkPswd to the text of field "password"
  197.   set isbad to 0
  198.   if the number of words in checkPswd > 1 then
  199.     cursor(0)
  200.     alert("Please do not use blank spaces in your password.")
  201.     set isbad to 1
  202.   else
  203.     if the number of words in checkPswd = 0 then
  204.       set isbad to 1
  205.       go("confirmChangeToNoPswd")
  206.       cursor(0)
  207.     end if
  208.   end if
  209.   if isbad = 0 then
  210.     put EMPTY into field "Password"
  211.     go("ConfirmChangedPswd")
  212.     cursor(0)
  213.   end if
  214. end
  215.  
  216. on confirmOK
  217.   global cycleNo, userNo, currentCycleNo
  218.   initVars()
  219.   append(cycleNo, 1)
  220.   set currentCycleNo to 1
  221.   set userNo to count(cycleNo)
  222.   resetUserNames()
  223.   go("bioData")
  224.   cursor(0)
  225. end
  226.  
  227. on initVars
  228.   global relations, stamp, mucus, advice, comments, PeakDayNo, bioInfo, usrName, pswd, askedToKeepChartin, forewarned, basis, warnYellow, previousPeak, bleedPeak, mucusNotPeak, goodbasisList
  229.   set askedToKeepChartin to 0
  230.   set forewarned to 0
  231.   set warnYellow to 0
  232.   set PeakDayNo to 0
  233.   set previousPeak to 0
  234.   set bleedPeak to 0
  235.   set mucusNotPeak to 0
  236.   set bioInfo to []
  237.   set relations to []
  238.   set stamp to []
  239.   set mucus to []
  240.   set advice to []
  241.   set basis to []
  242.   set comments to []
  243.   set endDate to 0
  244.   set beginDate to 0
  245.   set goodbasisList to [0, 101, 102, 103, 105, 106, 107, 108, 109, 111, 112, 113, 115, 117, 118, 119, 150, 201, 202, 203, 205, 206, 207, 208, 209, 210, 211, 215, 217, 218, 219, 125, 225, 126, 226]
  246.   put EMPTY into field "bioDataSummary"
  247. end
  248.  
  249. on capitalizeIT wordUp
  250.   set x to charToNum(char 1 of wordUp)
  251.   if (x < 123) and (x > 96) then
  252.     set NewWord to numToChar(x - 32) & chars(wordUp, 2, 30)
  253.     return NewWord
  254.   else
  255.     return wordUp
  256.   end if
  257. end
  258.  
  259. on newuser
  260.   global candidateUserName
  261.   if checkUserName(the text of field "username") then
  262.     set candidateUserName to word 1 of field "userName"
  263.     go("psWrd")
  264.     cursor(0)
  265.   end if
  266. end
  267.  
  268. on newUserName
  269.   global userNo, usrName
  270.   set newName to word 1 of field "username"
  271.   if checkUserName(newName) then
  272.     setAt(usrName, userNo, capitalizeIT(newName))
  273.     resetUserNames()
  274.     prepfrontpage()
  275.   end if
  276.   cursor(0)
  277. end
  278.  
  279. on checkUserName checkuser
  280.   global usrName
  281.   if (the number of words in checkuser > 1) or (the number of words in checkuser = 0) then
  282.     cursor(0)
  283.     alert("Please enter a one word username.")
  284.     set the text of field "username" to EMPTY
  285.     return 0
  286.   else
  287.     set x to count(usrName)
  288.     set checkuser to word 1 of checkuser
  289.     repeat with i = 1 to x
  290.       if checkuser = getAt(usrName, i) then
  291.         cursor(0)
  292.         alert("Sorry.  There is already a username similar to this one.  Please enter a different username.")
  293.         set the text of field "username" to EMPTY
  294.         return 0
  295.         set i to x + 1
  296.       end if
  297.     end repeat
  298.   end if
  299.   return 1
  300. end
  301.  
  302. on getSystemPath
  303.   if objectp(utilObj) then
  304.     utilObj(mdispose)
  305.   end if
  306.   if the machineType = 256 then
  307.     set utilObj to MovUtils(mnew)
  308.   else
  309.     set utilObj to MovieUtilities(mnew)
  310.   end if
  311.   if objectp(utilObj) then
  312.     set systemPath to utilObj(mGetSystemPath)
  313.     if the machineType = 256 then
  314.       set prefLOC to systemPath & "\"
  315.     else
  316.       set prefLOC to systemPath & "Preferences:"
  317.     end if
  318.     utilObj(mdispose)
  319.     return prefLOC
  320.   else
  321.     cursor(0)
  322.     alert("Sorry...Fatal Error: Can't write to System Folder!")
  323.   end if
  324. end
  325.  
  326. on makeAlist dataList
  327.   set x to the number of chars in dataList - 2
  328.   set the itemDelimiter to ","
  329.   set newList to []
  330.   set templist to chars(dataList, 2, x)
  331.   set x to the number of items in templist
  332.   repeat with i = 1 to x
  333.     if integerp(integer(item i of templist)) then
  334.       append(newList, integer(item i of templist))
  335.       next repeat
  336.     end if
  337.     append(newList, item i of templist)
  338.   end repeat
  339.   if not integerp(max(newList)) then
  340.     set newList to []
  341.   end if
  342.   return newList
  343. end
  344.  
  345. on StartNewCycle
  346.   global cycleNo, userNo, currentCycleNo, bioInfo
  347.   cursor(4)
  348.   puppetStatus(23, 48, 0)
  349.   if not anyFertileDay() and (count(stamp) > 12) then
  350.     setAnovul()
  351.     cursor(0)
  352.     alert("The previous cycle had no peak.  The cycle was either not charted in full, not charted correctly, or the cycle was ANOVULATORY.")
  353.   end if
  354.   set oldBioInfo to bioInfo
  355.   initVars()
  356.   set bioInfo to oldBioInfo
  357.   set x to getAt(cycleNo, userNo) + 1
  358.   setAt(cycleNo, userNo, x)
  359.   set currentCycleNo to x
  360.   resetUserNames()
  361.   writecycleinfo()
  362.   cursor(0)
  363.   alert("The previous chart was archived.  A new chart has been created for cycle #" && x & "." & RETURN & RETURN & "You must update your Biographical Data for the New Cycle.")
  364.   setUpBiodata()
  365. end
  366.  
  367. on makeCorrection
  368.   puppetSprite(7, 1)
  369.   set the visible of sprite 7 to 1
  370.   puppetSprite(7, 0)
  371.   updateStage()
  372.   repeat with i = 13 to 48
  373.     set the cursor of sprite i to [the number of member "eraser", the number of member "eraser"]
  374.   end repeat
  375. end
  376.  
  377. on killcorrection
  378.   repeat with i = 13 to 48
  379.     set the cursor of sprite i to 0
  380.   end repeat
  381. end
  382.  
  383. on roundUpAlways x
  384.   set framelocation to string(x)
  385.   set numberLoc to offset(".", framelocation) - 1
  386.   return chars(framelocation, 1, numberLoc)
  387. end
  388.  
  389. on positionNob
  390.   global firstMonthlyDay, stamp
  391.   set MaxScroll to float(count(stamp))
  392.   if firstMonthlyDay = 1 then
  393.     set NewPosition to 221
  394.   else
  395.     if (firstMonthlyDay + 11) = MaxScroll then
  396.       set NewPosition to 500
  397.     else
  398.       set NewPosition to ((firstMonthlyDay + 11) / MaxScroll * 279) + 220
  399.     end if
  400.   end if
  401.   set the locH of sprite 11 to NewPosition
  402.   updateStage()
  403. end
  404.  
  405. on prepBioDataSummary
  406.   global bioInfo, usrName, userNo
  407.   put " " into field "biodatasummary"
  408.   if max(bioInfo) = 15 then
  409.     if min(bioInfo) <> 1 then
  410.       put the text of field "profile 15" & RETURN & RETURN into field "bioDataSummary"
  411.     end if
  412.     set x to count(bioInfo)
  413.     repeat with i = 1 to x - 1
  414.       put i & ")  " after field "biodataSummary"
  415.       if (getAt(bioInfo, i) = 13) or (getAt(bioInfo, i) = 8) or (getAt(bioInfo, i) = 2) or (getAt(bioInfo, i) = 12) then
  416.         put the text of field ("profile 15-" & getAt(bioInfo, i)) & RETURN & RETURN after field "biodataSummary"
  417.         next repeat
  418.       end if
  419.       put the text of field ("profile" && getAt(bioInfo, i)) & RETURN & RETURN after field "biodataSummary"
  420.     end repeat
  421.   else
  422.     put the text of field "profile 14" & RETURN & RETURN into field "bioDataSummary"
  423.     set x to count(bioInfo)
  424.     repeat with i = 1 to x - 1
  425.       put i & ")  " after field "biodataSummary"
  426.       if (getAt(bioInfo, i) = 13) or (getAt(bioInfo, i) = 8) or (getAt(bioInfo, i) = 2) or (getAt(bioInfo, i) = 12) then
  427.         put the text of field ("profile 14-" & getAt(bioInfo, i)) & RETURN & RETURN after field "biodataSummary"
  428.         next repeat
  429.       end if
  430.       put the text of field ("profile" && getAt(bioInfo, i)) & RETURN & RETURN after field "biodataSummary"
  431.     end repeat
  432.   end if
  433.   put "Initial advice for " & getAt(usrName, userNo) & RETURN & RETURN before field "bioDataSummary"
  434.   go("bioData Summary")
  435.   cursor(0)
  436. end
  437.